import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lcapp/basic/user_info.dart';
import 'package:lcapp/config/const_config.dart';
import 'package:lcapp/page/min/min_gold_detail_page.dart';
import 'package:lcapp/page/min/min_money_detail_page.dart';
import 'package:lcapp/widget/custom_indicator.dart';
import 'package:lcapp/widget/custom_tabs.dart';

class MinMoneyPage extends StatefulWidget {
  const MinMoneyPage({Key? key}) : super(key: key);

  @override
  _MinMoneyPageState createState() => _MinMoneyPageState();
}

class _MinMoneyPageState extends State<MinMoneyPage> with SingleTickerProviderStateMixin {

  late TabController tabController;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    tabController = TabController(length: 2, vsync: this);
    refreshUserInfo(refreshBlock: (){setState(() {
    });});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: bgColor,
        body: Container(
          width: 1.sw,
          height: 1.sh,
          padding: EdgeInsets.only(bottom: ScreenUtil().bottomBarHeight),
          child: Stack(
            children: [
              Container(
                child: Image.asset('assets/min/min_top_bg.png',height: 500.w,width: 1.sw,fit: BoxFit.fill,),
              ),
              Positioned(
                child: Container(
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(10.w)
                  ),
                  padding: EdgeInsets.symmetric(horizontal: 30.w,vertical: 30.w),
                  height: 330.w,
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Container(
                        child: Column(
                          children: [
                            Text('${userInfo.gold??0}',style: TextStyle(
                                color: Colors.black,
                                fontSize: 40.sp,
                                fontWeight: FontWeight.w600
                            ),),
                            SizedBox(height: 20.w,),
                            Container(
                              height: 50.w,
                              child: Row(
                                children: [
                                  Icon(Icons.monetization_on_sharp,color: Color(0xffFF991D),size: 30.w,),
                                  SizedBox(width: 8.w,),
                                  Text('金币',style: TextStyle(
                                      color: Color(0xffFF991D),
                                      fontSize: 30.sp,
                                      fontWeight: FontWeight.w600
                                  ),)
                                ],
                              ),
                            ),
                            SizedBox(height: 40.w,),
                            GestureDetector(
                              onTap: (){
                                Navigator.of(context).pushNamed('MinChangeJiinbiPage').then((value){
                                  refreshUserInfo(refreshBlock: (){setState(() {
                                  });});
                                });
                              },
                              child: Container(
                                height: 75.w,
                                width: 160.w,
                                alignment: Alignment.center,
                                decoration: BoxDecoration(
                                    color: Color(0xffFFE19C),
                                    borderRadius: BorderRadius.circular(75.w)
                                ),
                                child: Text('换现金',style: TextStyle(
                                    color: Color(0xffF1921D),
                                    fontSize: 30.sp,
                                    fontWeight: FontWeight.w600
                                ),),
                              ),
                            ),
                          ],
                          mainAxisAlignment: MainAxisAlignment.center,
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.symmetric(horizontal: 60.w),
                        height: 280.w,
                        width: 1,
                        color: Color(0xffE9E8E9),
                      ),
                      Container(
                        child: Column(
                          children: [
                            Text('${userInfo.cash??0}',style: TextStyle(
                                color: Colors.black,
                                fontSize: 40.sp,
                                fontWeight: FontWeight.w600
                            ),),
                            SizedBox(height: 20.w,),
                            Container(
                              height: 50.w,
                              child: Image.asset('assets/min/min_xj.png',width: 100.w,),
                            ),
                            SizedBox(height: 40.w,),
                            GestureDetector(
                              onTap: (){
                                Navigator.of(context).pushNamed('MinGetMoneyPage').then((value){
                                  refreshUserInfo(refreshBlock: (){setState(() {
                                  });});
                                });
                              },
                              child: Container(
                                height: 75.w,
                                width: 160.w,
                                alignment: Alignment.center,
                                decoration: BoxDecoration(
                                    color: Color(0xffFF4E3D),
                                    borderRadius: BorderRadius.circular(75.w)
                                ),
                                child: Text('提现',style: TextStyle(
                                    color: Colors.white,
                                    fontSize: 30.sp,
                                    fontWeight: FontWeight.w600
                                ),),
                              ),
                            ),
                          ],
                          mainAxisAlignment: MainAxisAlignment.center,
                        ),
                      ),
                    ],
                  ),
                ),
                left: 100.w,right: 100.w,top: ScreenUtil().statusBarHeight+10.w+80.w+30.w,),
              Positioned(child: Container(
                child: Row(
                  children: [
                    GestureDetector(
                      onTap: (){
                        Navigator.of(context).pop();
                      },
                      child: Container(
                        width: 100.w,
                        height: 80.w,
                        alignment: Alignment.centerLeft,
                        child: Icon(Icons.arrow_back_ios,color: Colors.white,size: 40.w,),
                      ),
                    ),
                    Expanded(child: Container(
                      alignment: Alignment.center,
                      child: Text('我的钱包',style: TextStyle(
                          color: Colors.white,
                          fontSize: 36.sp,
                          fontWeight: FontWeight.w600
                      ),),
                    )),
                    Container(
                      width: 100.w,
                      height: 80.w,
                    ),
                  ],
                ),
              ),top: ScreenUtil().statusBarHeight+10.w,left: 30.w,right: 30.w,),
              Positioned(child: Container(
                margin: EdgeInsets.only(top: 60.w),
                padding: EdgeInsets.all(30.w),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(20.w)
                ),
                child: Column(
                  children: [
                    Container(
                      height: 80.w,
                      width: 400.w,
                      child: TabBar(
                        controller: tabController,
                        // indicator: CustomIndicator(
                        //     type: CustomIndicatorType.LineRect,
                        //     height: 2,
                        //     width: 40.w,
                        //     color: Color(0xffEE773A)),
                        labelColor: Color(0xffEE773A),
                        labelStyle: TextStyle(
                          fontSize: 40.sp,
                          color: Color(0xffEE773A),
                          fontWeight: FontWeight.w600,
                        ),
                        unselectedLabelColor: Colors.black,
                        unselectedLabelStyle: TextStyle(
                          fontSize: 30.sp,
                          color: Colors.black,
                          fontWeight: FontWeight.w400,
                        ),
                        tabs: const [
                          Text("金币明细"),
                          Text("现金明细"),
                        ],
                      ),
                    ),
                    Expanded(child: TabBarView(
                      controller: tabController,
                      children: [
                        MinGoldDetailPage(),
                        MinMoneyDetailPage(),
                      ],
                    ))
                  ],
                ),
              ),left: 30.w,right: 30.w,top: ScreenUtil().statusBarHeight+10.w+80.w+30.w+300.w,bottom: 0,)
            ],
          ),
        )

    );
  }

}
